<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 错误的打印时间
      // let p1 = new Promise((resovle, reject) => {
      //   setTimeout(() => {
      //     resovle(1);
      //   }, 1000);
      // });

      // let p2 = p1.then((res) => {
      //   console.log("then", res);
      //   // return 5;
      // });
      let p3 = Promise.resolve(3);
      let p4 = Promise.reject(4);
      // p4.catch((reason) => {
      //   console.log(reason);
      // });
      // todo 发现这两种结果不一样 Promise.resolve(p4);不会报错 结果是一个普通值
      // Promise.reject(p4)报错 且失败的原因是一个promise不是一个普通值
      let p5 = Promise.reject(p4);
      // let p5 = Promise.resolve(p4);

      p5.then(
        (value) => {
          console.log("value", value);
        },
        (reason) => {
          console.log("reason", reason);
        }
      );
    </script>
  </body>
</html>
